using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using GraphFS;
using GPSNav.NET;

namespace GraphFSGUI
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
			map = new GpsMap("", IAccessType.SQLite);
		}

		GpsMap map = null;
		private void button1_Click(object sender, EventArgs e)
		{
			Graphics g = this.CreateGraphics();
			g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

			/*FSGraph gr = new FSGraph("map6");
			GraphDraw.DrawGraph(gr, 1, 10, 282054027, g, this.Bounds);*/

			/*FSGraph gr = new FSGraph("digestRomanica",IAccessType.SQLite);
			GraphDraw.DrawGraph(gr, 1, 10, 285999093, g, this.Bounds);*/


			//GraphDraw.DrawGraph(gr, 1, 10, 285999093, g, this.Bounds);
			//GpsRenderer.DrawGraph(map, 3, 10, 285999093, g, new Rectangle(Point.Empty, this.Size));




		}


		float zoom = 0.1f;

		private void button2_Click(object sender, EventArgs e)
		{
			Graphics g;
			//g= this.CreateGraphics();
			//g = panel2.CreateGraphics();
			
			//GpsRenderer.DrawGraph(map, 20, 1, 285999093, g, new Rectangle(Point.Empty, this.Size));
			//GpsRenderer.DrawGraph(map, 20,800, new GeoPoint(45.4816,25.9158), g, new Rectangle(Point.Empty, this.Size));
			//GpsRenderer.DrawGraph(map, 20, 2, new GeoPoint(45.4816, 25.9158), g, new Rectangle(Point.Empty, this.Size));
			//45.4805,25.9176

			

			int lod = 20;
			if (zoom < 50)
				lod = 12;
			if (zoom < 20)
				lod = 10;
			if (zoom < 6)
				lod = 8;
			if (zoom < 2)
				lod = 6;
			if (zoom < 1)
				lod = 4;
			if (zoom < 0.5f)
				lod = 1;



			Rectangle r = new Rectangle(Point.Empty,panel2.Size);
			//r.Offset(10, 10);
			Bitmap b=new Bitmap(r.Width,r.Height);



			//r.Inflate(-10, -10);


			g = Graphics.FromImage(b);

			label2.Visible = true;
			label2.Refresh();
			GpsRenderer.Instance.DrawGraph(map, lod, zoom, new GeoPoint(45.65, 25.6126), g, r);
			label2.Visible = false;

			panel2.CreateGraphics().DrawImage(b, 0, 0);

			//GpsRenderer.Instance.DrawGraph(map, lod, zoom, new GeoPoint(45.65, 25.6126), g, new Rectangle(new Point(20,20),s));
			//GpsRenderer.DrawGraph(map, lod, zoom, new GeoPoint(45.65, 25.6126), g, new Rectangle(Point.Empty, this.Size));
			//lat=45.65&lon=25.6126

		}

		private void button3_Click(object sender, EventArgs e)
		{

			zoom /= 1.5f;
			label1.Text = zoom.ToString();
			button2_Click(null, null);

		}

		private void button4_Click(object sender, EventArgs e)
		{
			zoom *= 1.5f;
			label1.Text = zoom.ToString();
			button2_Click(null, null);
		}

		private void button5_Click(object sender, EventArgs e)
		{
			zoom = 250.0f;
			label1.Text = zoom.ToString();
			button2_Click(null, null);
		}
	}
}